<style>
    #user-add {
        padding: 20px 25px 25px 0;
    }
    #user-add .layui-treeSelect .ztree li a, .ztree li span {
        margin: 0 0 2px 3px !important;
    }
</style>
<div class="layui-fluid" id="user-add">
    <form class="layui-form" action="" lay-filter="user-add-form">
        <div class="layui-form-item">
            <label class="layui-form-label febs-form-item-require">类型：</label>
            <div class="layui-input-block">
                <select name="type" id="type">
                    <option value="1">裸石</option>
                    <option value="2">半成品</option>
                    <option value="3">成品</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">名称：</label>
            <div class="layui-input-block">
                <input type="text" name="name" id="name"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">编号：</label>
            <div class="layui-input-block">
                <input type="text" name="number" id="number" maxlength="50"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label febs-form-item-require">规格：</label>
            <div class="layui-input-block">
                <input type="text" name="specifications" id="specifications" maxlength="50"   class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">形状：</label>
            <div class="layui-input-block">
                <select name="shape" id="shape">
                    <option value="1">水滴</option>
                    <option value="2">八角</option>
                    <option value="3">圆</option>
                    <option value="4">椭圆</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label febs-form-item-require">大小：</label>
            <div class="layui-input-block">
                <input type="text" name="singlePrice" id="singlePrice"  maxlength="50"   class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label febs-form-item-require">单颗单价：</label>
            <div class="layui-input-block">
                <input type="text" name="size" id="size"  maxlength="50"   class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">数量：</label>
            <div class="layui-input-block">
                <input name="amount" id="amount" maxlength="50" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">重量：</label>
            <div class="layui-input-block">
                <input name="weight" id="weight" maxlength="50" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">克拉单价：</label>
            <div class="layui-input-block">
                <input name="caratSinglePrice" id="caratSinglePrice" maxlength="50" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">总价：</label>
            <div class="layui-input-block">
                <input name="totalPrice" id="totalPrice" maxlength="50" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">汇率：</label>
            <div class="layui-input-block">
                <input name="exchangeRate" id="exchangeRate" maxlength="50" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item febs-hide">
            <button class="layui-btn" lay-submit="" lay-filter="user-add-form-submit" id="submit"></button>
            <button type="reset" class="layui-btn" id="reset"></button>
        </div>
    </form>
</div>

<script>
    layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect'], function () {
        var $ = layui.$,
            febs = layui.febs,
            layer = layui.layer,
            formSelects = layui.formSelects,
            treeSelect = layui.treeSelect,
            form = layui.form,
            $view = $('#user-add'),
            validate = layui.validate;

        form.verify(validate);
        form.render();

        formSelects.render();

     /*   treeSelect.render({
            elem: $view.find('#user-add-dept'),
            type: 'get',
            data: ctx + 'dept/select/tree',
            placeholder: '请选择',
            search: false
        });

        formSelects.config('user-add-role', {
            searchUrl: ctx + 'role',
            response: {
                statusCode: 200
            },
            beforeSuccess: function (id, url, searchVal, result) {
                var data = result.data;
                var tranData = [];
                for (var i = 0; i < data.length; i++) {
                    tranData.push({
                        name: data[i].roleName,
                        value: data[i].roleId
                    })
                }
                result.data = tranData;
                return result;
            },
            error: function (id, url, searchVal, err) {
                console.error(err);
                febs.alert.error('获取角色列表失败');
            }
        });*/

        form.on('submit(user-add-form-submit)', function (data) {

            febs.post(ctx + 'warehouse/add', data.field, function () {
                layer.closeAll();
                febs.alert.success('入库成功');
                $('#febs-user').find('#query').click();
            });
            return false;
        });
    });
</script>